In [2]:
import nibabel as nib
fp = '/home/grg/upf/Data/RM/rch2.nii'
im = nib.load(fp)
print im.header.keys()
print im.header['pixdim']
In [4]:
%matplotlib inline
im.orthoview()
Out[4]:
In [5]:
from matplotlib import pyplot as plt
import numpy as np
d_t1 = np.array(im.dataobj)
d2 = d_t1[35,:,:]
plt.imshow(d2)
Out[5]:
In [6]:
fp2 = '/home/grg/upf/Data/RM/rch2_wm.nii'
wm = nib.load(fp2)
d_wm = np.array(wm.dataobj)
wm.orthoview()
Out[6]:
In [7]:
fp3 = '/home/grg/upf/Data/Control/norm2ROI2wscan001.nii'
im2 = nib.load(fp3)
#pet1.orthoview()
pet1 = np.array(im2.dataobj)
m = pet1[d_wm>0.8].mean()
print m
plt.hist(pet1[d_wm>0.8])
Out[7]:
In [16]:
d_t1[d_wm>0.8] = 0
plt.imshow(d2) # d2 is the sagittal slice
#test = nib.Nifti1Image(d_t1, im.affine)
#test.to_filename('/tmp/test.nii.gz')
Out[16]:
In [36]:
from nilearn import plotting
In [46]:
plotting.
plotting.plot_glass_brain(im) #, colorbar=True, title='PET exam', black_bg=True, threshold=260)
Out[46]:
In [53]:
plotting.plot_stat_map(im2, bg_img=im, threshold=260)
Out[53]:
In [55]:
plotting.plot_stat_map(im2, bg_img=im, threshold=260, display_mode='z', cut_coords=range(-10,10,2))
Out[55]:
In [54]:
roi_fp = '/home/grg/spm/ROIapoE/ROI_DARTEL/csf5/rois.nii.gz'
plotting.plot_roi(roi_fp)
Out[54]:
In [19]:
from nilearn import image
image.
Check nilearn website
http://nilearn.github.io/modules/reference.html#module-nilearn.image
In [57]:
import nipype
Check nipype IPython notebooks